<?php
/**
 * Netflix_Queue class.
 * 
 * @author Armando Padilla, armando_padilla_81@yahoo.com
 * @package Zend_Service_Netflix
 */
class Netflix_Queue {

	/**
	 * Queue Item Id
	 * API Ref URL.
	 *
	 * @var unknown_type
	 */
	public $id;
	
	/**
	 * Position in the Queue.
	 *
	 * @var unknown_type
	 */
	public $position;
	
	/**
	 * Type of queue.  
	 * awaiting_release, available_now, saved
	 *
	 * @var unknown_type
	 */
	public $type; 
	
	/**
	 * API Ref URL.
	 *
	 * @var unknown_type
	 */
	public $queueRefURL;
	
	/**
	 * Last updated date.
	 *
	 * @var unknown_type
	 */
	public $updated;
	
	/**
	 * Title.
	 *
	 * @var unknown_type
	 */
	public $title;
	
	public function __construct(){}
	
	/**
	 * Enter description here...
	 *
	 * @param unknown_type $simpleXMLObject
	 */
	public function loadXML($queueItemXml){
		
		//Set all property values.
		$this->queueId  = (string)$queueItemXml->id;
		$this->position = (string)$queueItemXml->position;
		$this->updated  = (string)$queueItemXml->updated;
		$this->title    = (string)$queueItemXml->title;
		
		foreach($queueItemXml->link as $link){
			
			//Initialize variables.
			$href  = $link['href'];
			$title = $link['title']; 
			$rel   = $link['rel'];
			
			//queue ref.
			if($rel == "queue ref"){
				
				$this->queueRefURL = $href;
			}
		
			
		}
		
		foreach($queueItemXml->category as $category){
			
			//Initialize variables.
			$label  = (string)$category['label'];
			$scheme = (string)$category['scheme'];
			 
			//set queue type
			if(strpos($scheme, "queue_availability")){
				$this->type = $label;
			}
			
		}
		
		
	}
	
}
?>